package cn.cwkizq.springmvctest.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.remoting.exception.RemotingException;
import com.gome.rocketmq.client.extension.MessageProducer;

@Controller
@RequestMapping("/msg")
public class MessageController {
	@Autowired
	private MessageProducer msgSender;
	@ResponseBody
	@RequestMapping(value="/order/{orderid}")
	/**
	 * url:http://localhost:8080/springmvctest-web/msg/order/1234
	 * */
	public String sendMsg(@PathVariable String orderid) {
		System.out.println("send orderid:"+orderid);
		try {
			msgSender.send(orderid, orderid);
		} catch (Exception e) {
			e.printStackTrace();
		    return "errors";
		}
		return "success";
	}
	

}
